package com.gblfy.email.service.impl;

import com.gblfy.email.consts.EmailConst;
import com.gblfy.email.dto.Emailsubject;
import com.gblfy.email.mapper.EmailMpper;
import com.gblfy.email.service.EmailService;
import com.gblfy.email.util.EmailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {

    @Autowired
    private EmailMpper emailMpper;

    /**
     * 对账结果通知邮件模板
     */
    @Override
    public String checkInformEmailNotice() {
        //真实需求实战
        Emailsubject emailsubject = emailMpper.selectEmailMsg(EmailConst.EMAIL_FLAG);

        // 邮件公共部分  邮件正文以及主题根据实际业务动态拼接即可
        String named = "运维人员";//称呼
        int totalNum = 5;//对账批次总个数
        int succBatchNum = 5;//对账成功批次个数
        String checkInformSucc = "0123456IC20211012000001,0123456IC20211012000002";//对账成功批次
        String checkInformMiddle = "IC20211012000002";//对账中批次
        String checkInformDiff = "0123456IC20211012000004,0123456IC20211012000005";//对账差异批次

        try {
            return EmailUtils.checkInformEmailNotice(named, totalNum, succBatchNum, checkInformSucc,
                    checkInformMiddle, checkInformDiff, emailsubject.getProxyserverHost(),
                    emailsubject.getSendEmail(), emailsubject.getSendEmailPwd(), emailsubject.getReceiveEmail(), emailsubject.getCcEmail(), null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 数据装载通知邮件模板
     *
     * @return
     */
    @Override
    public String loadEmailNotice() {
        //真实需求实战
        Emailsubject emailsubject = emailMpper.selectEmailMsg(EmailConst.EMAIL_FLAG);

        String named = "运维人员";//称呼
        int totalLoadNum = 5;//装载总批次个数
        int loadAllSuccNum = 5;//装载全部成功批次个数
        String loadMiddle = "0123456IC20211012000001,0123456IC20211012000002";//装载中批次
        String LoadAllSucc = "IC20211012000002";//装载全部成功批次
        String partLoadSucc = "0123456IC20211012000004,0123456IC20211012000005";//装载部分成功批次
        String withoutLoad = "0123456IC20211012000008";//尚未装载批次

        try {
            return EmailUtils.loadEmailNotice(named, totalLoadNum, loadAllSuccNum, loadMiddle,
                    LoadAllSucc, partLoadSucc, withoutLoad, emailsubject.getProxyserverHost(),
                    emailsubject.getSendEmail(), emailsubject.getSendEmailPwd(), emailsubject.getReceiveEmail(), emailsubject.getCcEmail(), null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
